package misp_backend.config;


import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import jakarta.annotation.PostConstruct;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties(prefix = "alipay")
public class AlipayConfig {
    private String appId;
    private String appPrivateKey;
    private String alipayPublicKey;
    private String notifyUrl;
    private String returnUrl;

    @PostConstruct
    public void init(){
        Config config=new Config();
        config.protocol="https";
        config.gatewayHost="openapi-sandbox.dl.alipaydev.com";
        config.signType="RSA2";
        config.appId=this.appId;
        config.merchantPrivateKey=this.appPrivateKey;
        config.alipayPublicKey=this.alipayPublicKey;
        config.notifyUrl=this.notifyUrl;
        Factory.setOptions(config);
        System.out.println("支付宝SDK初始化成功！");

    }
}
